From e350a7f1b3f7faf04e6a75980dc6ca69523671dd Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 30 Dec 2025 14:39:05 +0100 Subject: [PATCH] screenShield: Drop seat state check after grabs Grabs are non-failable now, we do not need to check for the backend seat actually having been able to perform the request. Part-of: --- js/ui/screenShield.js | 53 ++++++++----------------------------------- 1 file changed, 10 insertions(+), 43 deletions(-) diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index 6803d3f03..9af1f791a 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -112,7 +112,7 @@ export class ScreenShield extends Signals.EventEmitter { this._lockSettings = new Gio.Settings({schema_id: LOCKDOWN_SCHEMA}); this._lockSettings.connect(`changed::${DISABLE_LOCK_KEY}`, this._syncInhibitor.bind(this)); - this._isModal = false; + this._grab = null; this._isGreeter = false; this._isActive = false; this._isLocked = false; @@ -191,19 +191,12 @@ export class ScreenShield extends Signals.EventEmitter { } _becomeModal() { - if (this._isModal) - return true; - - const grab = Main.pushModal(Main.uiGroup, {actionMode: Shell.ActionMode.LOCK_SCREEN}); - - // We expect at least a keyboard grab here - this._isModal = (grab.get_seat_state() & Clutter.GrabState.KEYBOARD) !== 0; - if (this._isModal) - this._grab = grab; - else - Main.popModal(grab); + if (this._grab) + return; - return this._isModal; + this._grab = Main.pushModal(Main.uiGroup, { + actionMode: Shell.ActionMode.LOCK_SCREEN, + }); } async _syncInhibitor() { @@ -257,19 +250,7 @@ export class ScreenShield extends Signals.EventEmitter { return; } - if (!this._becomeModal()) { - // We could not become modal, so we can't activate the - // screenshield. The user is probably very upset at this - // point, but any application using global grabs is broken - // Just tell them to stop using this app - // - // XXX: another option is to kick the user into the gdm login - // screen, where we're not affected by grabs - Main.notifyError( - _('Unable to lock'), - _('Lock was blocked by an app')); - return; - } + this._becomeModal(); if (this._activationTime === 0) this._activationTime = GLib.get_monotonic_time(); @@ -339,14 +320,7 @@ export class ScreenShield extends Signals.EventEmitter { } showDialog() { - if (!this._becomeModal()) { - // In the login screen, this is a hard error. Fail-whale - const error = new GLib.Error( - Gio.IOErrorEnum, Gio.IOErrorEnum.FAILED, - 'Could not acquire modal grab for the login screen. Aborting login process.'); - global.context.terminate_with_error(error); - } - + this._becomeModal(); this.actor.show(); this._isGreeter = Main.sessionMode.isGreeter; this._isLocked = true; @@ -571,10 +545,9 @@ export class ScreenShield extends Signals.EventEmitter { if (this._dialog && !this._isGreeter) this._dialog.popModal(); - if (this._isModal) { + if (this._grab) { Main.popModal(this._grab); this._grab = null; - this._isModal = false; } this._longLightbox.lightOff(); @@ -669,13 +642,7 @@ export class ScreenShield extends Signals.EventEmitter { return; } - // Warn the user if we can't become modal - if (!this._becomeModal()) { - Main.notifyError( - _('Unable to lock'), - _('Lock was blocked by an app')); - return; - } + this._becomeModal(); // Clear the clipboard - otherwise, its contents may be leaked // to unauthorized parties by pasting into the unlock dialog's -- 2.39.5